<include file="Common:header"/>
    <div class="container content">
      <div class="panel panel-default">
      <!-- Default panel contents -->
      <div class="panel-heading">文章分类 <a href="javascript:;"   data-toggle="modal" data-target=".bs-example-modal-lg">添加分类</a></div>

      <!-- Table -->
      <table class="table">
        <thead>
          <tr>
            <th>id</th>
            <th>分类名称</th>
            <th>级别</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <foreach name="cates" item="v">
            <tr>
              <th scope="row">{$v.id}</th>
              <td>{$v.name}</td>
              <td>{$v.lv}</td>
              <td>
                <a class="btn btn-success btn-xs update" cid="{$v.id}" data-toggle="modal" data-target=".bs-update-modal-lg">修改</a>
                <a href="{:U('Article/delCate',array('id'=>$v['id']))}" class="btn btn-danger btn-xs">删除</a>
              </td>
            </tr>
          </foreach>
        </tbody>
      </table>
    </div>
    </div>
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
      <div class="modal-dialog modal-lg">
        <form action="{:U('Article/addCate')}" method="post">
        <div class="modal-content">
          <h6>添加分类</h6>
          <div class="form-group">
                <label>级别</label>
                <input name="lv" type="number" class="form-control"  >
                <label>分类名称 </label>
                <input name="name" type="text" class="form-control" >
          </div>
            <button type="submit" class="btn btn-primary btn-lg btn-block">添加</button>
        </div>
        </form>
      </div>
    </div>
    <div class="modal fade bs-update-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
      <div class="modal-dialog modal-lg">
        <form action="{:U('Article/updateCate')}" method="post">
        <div class="modal-content">
          <h6>添加分类</h6>
          <div class="form-group">
              <input type="hidden" name="id">
                <label>级别</label>
                <input name="lv" type="number" class="form-control"  >
                <label>分类名称 </label>
                <input name="name" type="text" class="form-control" >
          </div>
            <button type="submit" class="btn btn-primary btn-lg btn-block">修改</button>
        </div>
        </form>
      </div>
    </div>
<include file="Common:js"/>
<script>
$('.update').click(function(){
  $('.bs-update-modal-lg input[name=id]').val($(this).attr('cid'));
})
</script>
</body>
</html>
